package mysql

import "gorm.io/gorm"

type Users struct {
	gorm.Model
	Account  string `gorm:"type:varchar(20);not null"`
	Password string `gorm:"type:char(32);not null"`
}

type UserRealNames struct {
	gorm.Model
	UsersId  int    `gorm:"type:int;not null"`
	IdCard   string `gorm:"type:varchar(18);not null"`
	RealName string `gorm:"type:varchar(20);not null"`
}

type Cars struct {
	gorm.Model
	Brand      string  `gorm:"type:varchar(30);not null"`
	Models     string  `gorm:"type:varchar(30);not null"`
	License    string  `gorm:"type:varchar(30);not null"`
	Price      float64 `gorm:"type:decimal(10,2);not null"`
	Mileage    int64   `gorm:"type:int;not null"`
	Categories int64   `gorm:"type:int;not null"`
	Image      string  `gorm:"type:varchar(255);not null"`
	UsersId    int     `gorm:"type:int;not null"`
}

func (r *UserRealNames) RealList() error {
	return DB.Where("id = ?", r.UsersId).Limit(1).Find(&r).Error
}

func (r *UserRealNames) RealAdd() error {
	return DB.Debug().Create(&r).Error
}
